package com.gitee.controller.user;

import com.gitee.entity.FansList;
import com.gitee.result.Result;
import com.gitee.service.FansListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/user/fansListController")
@Api(tags = "粉丝列表接口")
public class FansListController {

    @Resource
    private FansListService fansListService;

    @GetMapping("/getFans/{userId}")
    @ApiOperation("获得粉丝列表")
    @Cacheable(cacheNames = "fansListCache", key = "#userId")
    public Result<List<FansList>> getFans(@PathVariable Integer userId) {
        log.info("获得粉丝列表: {}", userId);
        return Result.success(fansListService.getFans(userId));
    }
}
